﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Card.Web
{
    public partial class Login : BasePage
    {
        #region 属性

        #endregion

        #region 事件
        protected override void OnInit(EventArgs e)
        {
            this.btnLogin.Click += new EventHandler(btnLogin_Click);           
            base.OnInit(e);
        }


        void btnLogin_Click(object sender, EventArgs e)
        {
            if (this.DoCheck())
            {
                string message = string.Empty;
                if (Common.LoginUtility.Login(this.txtLoginName.Text, this.txtLoginPW.Text, this.autologin.Checked, ref message, this.Passport))
                {
                    Response.Redirect("/");
                }
                else
                {
                    this.MessageBox(message);
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        #endregion

        #region 方法
        private bool DoCheck()
        {
            if (string.IsNullOrEmpty(this.txtLoginName.Text))
            {
                this.MessageBox("请输入登录名！");
                return false;
            }

            if (string.IsNullOrEmpty(this.txtLoginPW.Text))
            {
                this.MessageBox("请输入密码！");
                return false;
            }

            return true;
        }
        
        #endregion
    }
}
